package google.language
{
        import smashedapples.google.GoogleLanguageApi;
        import smashedapples.google.language.GoogleLanguageResponse;
        import smashedapples.google.language.LangPairVO;
        import smashedapples.core.Command;
        import smashedapples.core.Component;
        import smashedapples.core.Controller;
        
        use namespace overload;
        
        public class GoogleLanguageController extends Controller
        {

        	public function translate(command:Command):void
            {       
                        
            	if(command.isViewType(GoogleLanguageScreen))
                	overload::translate( command, (command.view as GoogleLanguageScreen).originalText.text,
                                        (command.view as GoogleLanguageScreen).selectedLanguagePair.selectedItem as LangPairVO);
                                                
        
            }
                
		    overload function translate(command:Command,originalText:String,langPair:LangPairVO):void
		    {
		    	GoogleLanguageApi.Static.createRequest(command,originalText,langPair,this.translateResponse).send();
		    }
        
            private function translateResponse(response:GoogleLanguageResponse):void
            {
    
                    if(response.command.isViewType(GoogleLanguageScreen))
                            (response.command.view as GoogleLanguageScreen).translatedText.text = response.translatedText;
                            
                    
            }
            
                
                
                
        }
}
